/**
 * @author 王斌
 */
$(document).ready(function(){
	initEvent();
});

//初始化事件
initEvent = function(){
	$("#nowWarn").click(function(){
		setTab("nowWarn");
	});
	$("#historyWarn").click(function(){
		setTab("historyWarn");
	});
	$("#analysis").click(function(){
		setTab("analysis");
		drawCharts();
		//$.jqplot('draw',  [[[1, 4],[3,5],[5,11],[7,33],[9,68],[11,80]]]);
	});
}

drawCharts = function(){
var cosPoints = [];
  for (var i=0; i<2*Math.PI; i+=1){ 
    cosPoints.push([i, Math.cos(i)]); 
  }
    
  var sinPoints = []; 
  for (var i=0; i<2*Math.PI; i+=0.4){ 
     sinPoints.push([i, 2*Math.sin(i-.8)]); 
  }
    
  var powPoints1 = []; 
  for (var i=0; i<2*Math.PI; i+=1) { 
      powPoints1.push([i, 2.5 + Math.pow(i/4, 2)]); 
  }
    
  var powPoints2 = []; 
  for (var i=0; i<2*Math.PI; i+=1) { 
      powPoints2.push([i, -2.5 - Math.pow(i/4, 2)]); 
  } 
 
  var plot3 = $.jqplot('drawChart', [cosPoints, sinPoints, powPoints1, powPoints2], 
    { 
      title:'性能图', 
      seriesDefaults: {
          rendererOptions: {
              smooth: true
          }
      },
      series:[ 
          {
            lineWidth:2, 
            markerOptions: { style:'dimaond' }
          }, 
          {
            showLine:false, 
            markerOptions: { size: 7, style:"x" }
          },
          { 
            markerOptions: { style:"circle" }
          }, 
          {
            lineWidth:5, 
            markerOptions: { style:"filledSquare", size:10 }
          }
      ]
    }
  );
}

function setTab(name){
	$("#three_btn").children().removeClass("hover");
	$("#"+name).addClass("hover");
	$(".mainPanel").children().hide();
	$("#"+name+"Panel").show();
}